package com.android.readcard.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.android.readcard.R;
import com.android.readcard.inter.SetBtListener;


/**
 * 配对弹窗
 */
public class ToSetBtDialog extends Dialog {
    private Activity context;
    private SetBtListener mSetBtListener;

    public ToSetBtDialog(Context context, SetBtListener mSetBtListener) {
        super(context, R.style.BtDialogStyle);
        this.context = (Activity) context;
        this.mSetBtListener = mSetBtListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.set_bt_dialog);
        TextView bt_ok = (TextView) findViewById(R.id.bt_ok);
        TextView bt_no = (TextView) findViewById(R.id.bt_no);
        bt_no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSetBtListener.clickButn();
                dismiss();
            }
        });
        bt_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
                context.startActivity(intent);
                mSetBtListener.clickButn();
                dismiss();
            }
        });
        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);
    }
}
